﻿using ASoft.WPF.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ASoft.WPF.View
{
    /// <summary>
    /// PLCView.xaml 的交互逻辑
    /// </summary>
    public partial class PLCView : Window
    {
        public PLCView()
        {
            InitializeComponent();
        }

        private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var tab = ((TabControl)sender);
            var tabItem = tab.SelectedItem as TabItem;
            if (tabItem == null || tabItem.Equals(tab.Tag))
            {
                return;
            }
            tab.Tag = tabItem;
            if (tabItem.Equals(tabSystemSet) || tabItem.Equals(tabValidRoom))
            {
                tabItem.DataContext = (new ViewModelLocator()).系统设置;
                btnAllSave.Visibility = Visibility.Hidden;
            }
            else if (tabItem.Equals(tabPhone))
            {
                btnAllSave.Visibility = Visibility.Hidden;
            }
            else
            {
                btnAllSave.Visibility = Visibility.Visible;
            }
            if (tabItem.Equals(tabPhone))
            {
                tabItem.DataContext = (new ViewModelLocator()).手机设置;
            }

        }

        private void btnLed_Click(object sender, RoutedEventArgs e)
        {
            LedSetting ledSetting = new LedSetting();
            this.Hide();
            ledSetting.ShowDialog();
            this.Show();
        }
    }
}
